package ${package.controller};

import ${package.model}.${table.entity};
import ${package.service}.${table.service};
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/${table.lowerCaseEntity}")
@Api(tags = "${table.entity} Controller")
public class ${table.entity}Controller {

@Autowired
private ${table.service} ${table.lowerCaseEntity}Service;

@PostMapping
@ApiOperation("Add new ${table.entity}")
public boolean add(@RequestBody ${table.entity} entity) {
return ${table.lowerCaseEntity}Service.save(entity);
}

@PutMapping
@ApiOperation("Update ${table.entity}")
public boolean update(@RequestBody ${table.entity} entity) {
return ${table.lowerCaseEntity}Service.updateById(entity);
}

@DeleteMapping("/{id}")
@ApiOperation("Delete ${table.entity} by ID")
public boolean delete(@PathVariable Long id) {
return ${table.lowerCaseEntity}Service.removeById(id);
}

@GetMapping("/{id}")
@ApiOperation("Get ${table.entity} by ID")
public ${table.entity} getById(@PathVariable Long id) {
return ${table.lowerCaseEntity}Service.getById(id);
}

@GetMapping
@ApiOperation("Get all ${table.entity}s")
public List<${table.entity}> getAll() {
return ${table.lowerCaseEntity}Service.list();
}
}
